package exception;

import java.io.FileOutputStream;
import java.io.IOException;

/**
 * finally在IO中的应用
 *
 * @author Luka
 * @date 2021/05/31 16:46
 **/
public class FinallyDemo2 {
    public static void main(String[] args) {
        //向文件中写入一个字节
        FileOutputStream fos = null;
        try {
            fos = new FileOutputStream("fos.dat");
            fos.write(1);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
        }
        try {
            if (fos!=null) {
                fos.close();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}